package belleza.relativa

class HomeController {

    /**
     * Dependency injection for the springSecurityService.
     */
    def springSecurityService

    /**
     * Default action; redirects to 'defaultTargetUrl' if logged in, /login/auth otherwise.
     */
    def index = {
        if (getSession().getAttribute("esInvitado") == null){
            getSession().setAttribute("esInvitado",false)
        }

        if (springSecurityService.isLoggedIn()) {
            redirect controller: 'perfilPrivado', action:  'indexUsuario'
        } else if (getSession().getAttribute("esInvitado")) {
            redirect controller: 'perfilPrivado', action:  'indexInvitado'
        }
        else {
            redirect controller: 'login', action: 'index'
        }
    }

}
